<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>加加减减</title>
</head>
<body>
    <div id="app">
        <ul>
            <li v-for="(item, index) in randomNumbers" :key="index">
                {{ item }}
                <button @click="removeNumber(index)">删除</button>
            </li>
        </ul>
        <button @click="addRandomNumber">生成</button>
    </div>
    <script src="./vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                randomNumbers: []
            },
            methods: {
                addRandomNumber() {
                    const randomNumber = Math.floor(Math.random() * 20) + 1;
                    this.randomNumbers.push(randomNumber);
                },
                removeNumber(index) {
                    this.randomNumbers.splice(index, 1);
                }
            }
        })
    </script>
</body>
</html>